package org.nlp2rdf.navigator.benchmark;

import org.aksw.commons.util.random.RandomUtils;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

/**
 * Created by Claus Stadler
 * Date: Oct 28, 2010
 * Time: 12:35:28 AM
 *
 * This class is unfinished.
 * The idea is to pick as many +/- samples from the source set, however, if less than n
 * are found, use the pool for additional samples.
 * The window parameter determines how many items of the source set to examine before falling back
 * on the pool. (Its like googling for a term, looking a the first page (the window), and rather than
 * moving to additional pages, change the query instead).
 */
public class RandomForceNPickingStrategy<E>
    implements IPickingStrategy<E>
{
    private int n;
    private int windowSize; // the window to search for positive examples (like only looking at the first page of a google result)
    private Random random;
    private Sample<E> fallbackPool; // the pool to draw additional positive examples from

    public RandomForceNPickingStrategy(int n, Random random, int windowSize, Sample<E> fallbackPool)
    {
        this.n = n;
        this.random = random;
        this.windowSize = windowSize;
        this.fallbackPool = Sample.createCopy(fallbackPool);
    }

    @Override
    public Sample<E> pick(Sample<E> source) {
        Sample<E> result = Sample.create(
                RandomUtils.randomSampleSet(source.getPositives(), n, random),
                RandomUtils.randomSampleSet(source.getNegatives(), n, random));

        //if(result.getPositives().size())

        return result;
    }
}
